<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class ingreso_reservaM extends CI_Model {

    public function __construct() {
        $this->load->database();
    }

    public function registrarPago($valor, $descripcion, $modoPago, $idReserva, $usuario) {
        $query = "INSERT INTO ingreso_reserva(id_reserva,fecha,valor,descripcion,modo_pago,usuario_encargado) VALUES('$idReserva',now(),'$valor','$descripcion','$modoPago','$usuario')";
        echo $query;
        return $this->db->query($query);
    }

    public function obtenerIngresos($idReserva) {
        $query = "SELECT COALESCE(SUM(valor),0) totalIngreso from ingreso_reserva WHERE id_reserva='$idReserva'";
        return $this->db->query($query)->result();
    }

    public function listarIngresos($idReserva) {
        $query = "SELECT * from ingreso_reserva WHERE id_reserva='$idReserva'";
        return $this->db->query($query)->result();
    }

}